package com.kede.controller;

import com.kede.entity.SystemInfo;
import com.kede.service.SystemInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class SysteminfoController {

    @Autowired
    SystemInfoService systemInfoService;

    @GetMapping("/systeminfo")
    public String systeminfo(){
        return "website_info";
    }

    @GetMapping("/config_system")
    public String syscon(){
        return "config_system";
    }

    @GetMapping("/config_upload")
    public String sysupload(){
        return "config_upload";
    }

    @PostMapping("/saveinfo")
    public String saveinfo
            (@RequestParam(value = "web_site_title") String webtitle,
             @RequestParam(value = "web_site_keywords")String webkey,
             @RequestParam(value = "web_site_description")String description){

        SystemInfo systemInfo = new SystemInfo();
        systemInfo.setWebtitle(webtitle);
        systemInfo.setWebkey(webkey);
        systemInfo.setDescription(description);
        systemInfoService.save(systemInfo);
        return "main";
    }
}
